<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
       <h3>数字 {{num}}</h3>
       <h3>姓名{{username}}</h3>
    </div>
    
</body>
<script>
    function  Vue(option){
        this.target = document.querySelector(option.el);//找到目标元素

        // this.target.innerHTML  = this.target.innerHTML.replace("{{num}}",option.data.num);
        // this.target.innerHTML = this.target.innerHTML.replace("{{username}}",option.data.username);
        // alert(this.target.innerHTML);
        //let  data = option.data;//
        let {data} = option;//解构
        //对象中的属性 在页面中出现了  就渲染出来
        // let  keys  = Object.keys(data);
        let html = this.target.innerHTML;
        for(let  attr  in data){  //num username
            // console.log(attr);
            html  = html.replace(`{{${attr}}}`,data[attr]);
        }
        this.target.innerHTML = html;

    }


    new  Vue({
            el:"#app",
            data:{
                num:99,
                username:"leson",
                age:18
            }
    })
    
</script>
</html>